import fetch from '@/config/fetch'

// 登录
var login = (mobile, password) =>
  fetch('POST', 'a/api/login', {
    mobile: mobile,
    password: password
  })
// 查询个人信息
var user = (userId, token) =>
  fetch('POST', `a/api/user/${userId}`, {
    userId: userId,
    token: token
  })
// 我的界面修改密码
var resetpass = (
  resetType,
  userId,
  token,
  oldPassword,
  password,
  refPassword
) =>
  fetch('PUT', `a/api/reset/${userId}`, {
    resetType: resetType,
    userId: userId,
    token: token,
    oldPassword: oldPassword,
    password: password,
    refPassword: refPassword
  })
// 忘记密码获取验证码
var smsAuthCode = (mobile, secret, sendType) =>
  fetch('POST', `a/api/smsAuthCode/${mobile}`, {
    mobile: mobile,
    secret: secret,
    sendType: sendType
  })
// 忘记密码修改密码
var resetPassword = (mobile, code, password, refPassword) =>
  fetch('PUT', `a/api/resetPassword/${mobile}`, {
    mobile: mobile,
    code: code,
    password: password,
    refPassword: refPassword
  })
// 我的界面修改手机
var resetphone = (resetType, userId, token, mobile, code) =>
  fetch('PUT', `a/api/reset/${userId}`, {
    resetType: resetType,
    userId: userId,
    token: token,
    mobile: mobile,
    code: code
  })
// 更改绑定手机获取验证码
var phoneCode = (mobile, secret, sendType) =>
  fetch('POST', `a/api/smsAuthCode/${mobile}`, {
    mobile: mobile,
    secret: secret,
    sendType: sendType
  })
// 设备设备列表
var devicelist = (userId, token, pageNo, pageSize, mainCode) =>
  fetch('POST', `a/api/device/list`, {
    userId: userId,
    token: token,
    pageNo: pageNo,
    pageSize: pageSize,
    mainCode: mainCode
  })
// 登录之后首页面各任务数量查询
var goToIndex = (userId, token) =>
  fetch('POST', `a/api/goToIndex`, {
    userId: userId,
    token: token
  })
// 本接口用于获取设备类型、设备名称、设备状态的下拉框的值
var device = (menuType, userId, token, deviceType) =>
  fetch('POST', `a/api/device/getMenuData`, {
    menuType: menuType,
    userId: userId,
    token: token,
    deviceType: deviceType
  })
// 显示厂家主机型号
var manufacturerModel = (
  findType,
  token,
  deviceType,
  deviceName,
  manufacturerModel
) =>
  fetch('POST', `a/api/manufacturerModel/list`, {
    findType: findType,
    token: token,
    deviceType: deviceType,
    deviceName: deviceName,
    manufacturerModel: manufacturerModel
  })
// 显示申请单列表
var actAllot = (userId, token, pageNo, pageSize) =>
  fetch('POST', `a/api/actAllot/list`, {
    userId: userId,
    token: token,
    pageNo: pageNo,
    pageSize: pageSize
  })
// 显示已完成列表
var finishData = (userId, token, pageNo, pageSize) =>
  fetch('POST', `a/api/actAllot/finishData`, {
    userId: userId,
    token: token,
    pageNo: pageNo,
    pageSize: pageSize
  })
// 显示仓库列表
var warehouse = (userId, token, pageNo, pageSize, findType) =>
  fetch('POST', `a/api/warehouse/list`, {
    userId: userId,
    token: token,
    pageNo: pageNo,
    pageSize: pageSize,
    findType: findType
  })
// 显示物料号
var deviceModel = (userId, token, pageNo, pageSize, findType, modelCode) =>
  fetch('POST', `a/api/deviceModel/list`, {
    userId: userId,
    token: token,
    pageNo: pageNo,
    pageSize: pageSize,
    findType: findType,
    modelCode: modelCode
  })
// 显示机构
var office = (
  userId,
  token,
  pageNo,
  pageSize,
  findType,
  officeType,
  shortName
) =>
  fetch('POST', `a/api/office/list`, {
    userId: userId,
    token: token,
    pageNo: pageNo,
    pageSize: pageSize,
    findType: findType,
    officeType: officeType,
    shortName: shortName
  })
// 显示仓库类型
var warehousetype = token =>
  fetch('POST', `a/api/warehouse/getMenuData`, {
    token: token
  })
// 显示待办任务列表
var actAllotTask = (userId, token) =>
  fetch('POST', `a/api/actAllot/task`, {
    userId: userId,
    token: token
  })
// 显示设备详情
var deviceDetail = (token, id) =>
  fetch('POST', `a/api/device/${id}`, {
    token: token,
    id: id
  })
// 申请调拨
var actApply = (
  token,
  userId,
  applyUnitId,
  applyUnitOfficeId,
  linkUserId,
  linkUserMobile,
  warehouseId,
  warehouseAddress,
  arriveDate,
  remarks,
  actApplyLogList
) =>
  fetch('POST', `a/api/actApply/apply`, {
    token: token,
    userId: userId,
    applyUnitId: applyUnitId,
    applyUnitOfficeId: applyUnitOfficeId,
    linkUserId: linkUserId,
    linkUserMobile: linkUserMobile,
    warehouseId: warehouseId,
    warehouseAddress: warehouseAddress,
    arriveDate: arriveDate,
    remarks: remarks,
    actApplyLogList: actApplyLogList
  })

export {
  login,
  user,
  resetpass,
  resetphone,
  phoneCode,
  smsAuthCode,
  resetPassword,
  devicelist,
  goToIndex,
  device,
  manufacturerModel,
  actAllot,
  finishData,
  warehouse,
  deviceModel,
  office,
  warehousetype,
  actAllotTask,
  deviceDetail,
  actApply
}
